﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Net;
using System.Web;

namespace KingSite.Library.Sms.SmsWrapper {
    public class SmsWrapper : ISms {
        ISmsSetting setting = new SmsSetting();

        public SmsWrapper() {
            this.SmsUrl = setting.SmsUrl;
        }

        public void Send(string mobileNumber, string message) {
            string sendUrl = this.SmsUrl;
            Encoding myEncoding = Encoding.GetEncoding("gb2312");
            sendUrl = String.Format("{0}&mobile={1}&message={2}", 
                          sendUrl, 
                          mobileNumber, 
                          HttpUtility.UrlEncode(message, myEncoding));
            Uri myUri = new Uri(sendUrl);
            HttpWebRequest myWebRequest = (HttpWebRequest)WebRequest.Create(myUri);
            myWebRequest.Method = "GET";
            WebResponse myWebResponse = myWebRequest.GetResponse();

            myWebResponse.Close();
        }

        public string SmsUrl {
            get;
            set;
        }
    }
}
